package com.easidea.tim.dao.purchase;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springside.core.dao.extend.HibernateEntityExtendDao;

import com.easidea.tim.entity.purchase.PurchaseReturn;

public class PurchaseReturnDao extends HibernateEntityExtendDao<PurchaseReturn>{
	
	 /**
	  *获取销售订单流水号和Id 
	  * @return
	  */
	   @SuppressWarnings("unchecked")
	public List<Object[]> getAllFlowNos() {
		   String hql = " select purchaseReturnNum,id from " + PurchaseReturn.class.getName() 
		   + " as s where s.deleted = 0";
		   return this.getHibernateTemplate().find(hql);
   }
	
	public List<PurchaseReturn> getOrderByOrderId(long orderId) {
		 Criteria ca = this.createUnDeletedCriteria();
		 ca.add(Restrictions.eq("id", orderId));
		 List result = ca.list();
		 return result;
	 }
	
	/**
	 * @author Harrison
	 * @param flowNo
	 * @return
	 */
	public PurchaseReturn getPurchaseByFlowNo(String flowNo){
		Criteria cte = createUnDeletedCriteria();
		cte.add(Restrictions.eq("flowNo", flowNo));
		return (PurchaseReturn)cte.uniqueResult();
	}

}
